package com.gemcoder.system.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.util.Map;
import javax.annotation.Resource;
import com.gemcoder.system.bo.Result;
import com.gemcoder.system.service.SparepartsmanagementService;
import cn.hutool.core.util.StrUtil;
import java.util.Map;
import cn.hutool.core.util.ObjectUtil;

@Controller
@RequestMapping("/Sparepartsmanagement")
public class SparepartsmanagementController {

    @Resource
    private SparepartsmanagementService SparepartsmanagementService;

    @RequestMapping(value = "/searchSpareParts")
    @ResponseBody
    public Result searchSpareParts(@RequestBody(required = false) Map<String, Object> paramMap) {
        //如果有需要校验的入参, 请在这里补充代码进行校验
        //调用service层的代码
        return SparepartsmanagementService.searchSpareParts(paramMap);
    }

    @RequestMapping(value = "/getAllSpareParts")
    @ResponseBody
    public Result getAllSpareParts(@RequestBody(required = false) Map<String, Object> paramMap) {
        //如果有需要校验的入参, 请在这里补充代码进行校验
        //调用service层的代码
        return SparepartsmanagementService.getAllSpareParts(paramMap);
    }

    @RequestMapping(value = "/addSparePart")
    @ResponseBody
    public Result addSparePart(@RequestBody(required = false) Map<String, Object> paramMap) {
        // 校验 Categoryvalue1
        if (paramMap.get("Categoryvalue1") == null || String.valueOf(paramMap.get("Categoryvalue1")).isEmpty()) {
            return new Result(false, "类别必填", null);
        }
        // 校验 Namevalue1
        if (paramMap.get("Namevalue1") == null || String.valueOf(paramMap.get("Namevalue1")).isEmpty()) {
            return new Result(false, "名称必填", null);
        }
        // 校验 Unitvalue1
        if (paramMap.get("Unitvalue1") == null || String.valueOf(paramMap.get("Unitvalue1")).isEmpty()) {
            return new Result(false, "单位必填", null);
        }
        // 校验 Quantityinstoragevalue1
        if (paramMap.get("Quantityinstoragevalue1") == null) {
            return new Result(false, "入库量必填", null);
        }
        // 校验 Outboundquantityvalue1
        if (paramMap.get("Outboundquantityvalue1") == null) {
            return new Result(false, "出库量必填", null);
        }
        //调用service层的代码
        return SparepartsmanagementService.addSparePart(paramMap);
    }

    @RequestMapping(value = "/updateSparePart")
    @ResponseBody
    public Result updateSparePart(@RequestBody(required = false) Map<String, Object> paramMap) {
        // 校验 Categoryvalue2
        if (paramMap.get("Categoryvalue2") == null || String.valueOf(paramMap.get("Categoryvalue2")).isEmpty()) {
            return new Result(false, "类别必填", null);
        }
        // 校验 Namevalue2
        if (paramMap.get("Namevalue2") == null || String.valueOf(paramMap.get("Namevalue2")).isEmpty()) {
            return new Result(false, "名称必填", null);
        }
        // 校验 Unitvalue2
        if (paramMap.get("Unitvalue2") == null || String.valueOf(paramMap.get("Unitvalue2")).isEmpty()) {
            return new Result(false, "单位必填", null);
        }
        // 校验 Quantityinstoragevalue2
        if (paramMap.get("Quantityinstoragevalue2") == null) {
            return new Result(false, "入库量必填", null);
        }
        // 校验 Outboundquantityvalue2
        if (paramMap.get("Outboundquantityvalue2") == null) {
            return new Result(false, "出库量必填", null);
        }
        //调用service层的代码
        return SparepartsmanagementService.updateSparePart(paramMap);
    }

    @RequestMapping(value = "/deleteSparePart")
    @ResponseBody
    public Result deleteSparePart(@RequestBody(required = false) Map<String, Object> paramMap) {
        //如果有需要校验的入参, 请在这里补充代码进行校验
        //调用service层的代码
        return SparepartsmanagementService.deleteSparePart(paramMap);
    }

    @RequestMapping(value = "/getAllSparePartsOZM")
    @ResponseBody
    public Result getAllSparePartsOZM(@RequestBody(required = false) Map<String, Object> paramMap) {
        //如果有需要校验的入参, 请在这里补充代码进行校验
        //调用service层的代码
        return SparepartsmanagementService.getAllSparePartsOZM(paramMap);
    }
}
